# -*- coding: utf-8 -*-
import redis
import requests
import json
import time
import pymysql


HOST = 'oyo-scrapy-database.mysql.rds.aliyuncs.com'
PORT = 3306
USER = 'scrapy'
PASSWD = 'Podf&T$2'
DB = 'spider'
CHARSET = 'utf8mb4'

conn = pymysql.connect(host=HOST, port=PORT, user=USER, passwd=PASSWD, db=DB,charset=CHARSET)
cur=conn.cursor()

RHOST = '10.200.20.200'
RPORT = 6379
RPASSWORD = 'zhangym930920'
RDB = 1
r = redis.Redis(host=RHOST, port=RPORT, db=RDB,charset='utf-8',password=RPASSWORD,decode_responses=True)
sql="SELECT sync_username,sync_password,CRS_ID,batch_no from ota_back_account_info where batch_no='2019011702' and ota_channel_en='qunar' and sync_username='13470020002'"
# sql="select hotel_name_cn,id,hotel_ota_url from a_sp_ota_hotel_detail where hotel_status=0 and hotel_id not in (SELECT REPLACE(hotel_id,'_','/dt-') from a_sp_ota_hotel_room_type GROUP BY hotel_id)"
cur.execute(sql)
datas=cur.fetchall()

for data in datas:
    CRS_ID=data[2]
    Ctrip_Username=data[0]
    Ctrip_Password=data[1]
    batch_no=data[3]

    print(Ctrip_Username,Ctrip_Password)
    r.rpush('hotel_users_qunar',(CRS_ID,Ctrip_Username,Ctrip_Password,batch_no))
